angular.module('Controller')

.controller 'MyselfCtrl', ($scope, $state,cryptUtil,commonUtil,userData,$localStorage,commonConstant,wfAlert,$http) ->
    _.extend $scope,
        userNav:[
            {id:'basic',name:'基本信息'}
            {id:'setting',name:'密码设置'}
        ]

        user:
            portrait:"images/nr-offical/NR-avatar.png"
        getUserInfo:->
            $http.get("/users/member/info")
            .success((resp)->
                if resp.code==0
                    $scope.user = resp.message
                    userData.setUser($scope.user)
                else
                    wfAlert.toastError(resp.message)
            )
        doLogout:->
            $http.get('/logout')
            .success((resp)->
                if resp.code==0
                    userData.reset()
                    $state.go('login')
            )
        pickNav:(item)->
            $scope.currentNav=item
    $scope.currentNav=$scope.userNav[0]
    $scope.getUserInfo()


